package ch07_GUI编程;

import javax.swing.JProgressBar;
import javax.swing.SwingConstants;

public class JProgressBarDemo {
	public static void main(String[] args) {
		BaseFrame f = new BaseFrame("JProgressBar Demo");
		JProgressBar pb1=new JProgressBar();
		pb1.setMinimum(0);
		pb1.setMaximum(100);
		pb1.setValue(50);
		pb1.setLocation(5, 5);
		pb1.setSize(130, 20);

		JProgressBar pb2 = new JProgressBar(-20,20);
		pb2.setValue(-10);
		int min = pb2.getMinimum();
		int max = pb2.getMaximum();
		int value = pb2.getValue();
		pb2.setString("已下载："+(value-min)*100/(max-min)+'%');
		pb2.setStringPainted(true);
		pb2.setLocation(5,85);
		pb2.setSize(160,20);

		JProgressBar pb3 = new JProgressBar(SwingConstants.VERTICAL);
		pb3.setIndeterminate(true);
		pb3.setString("不确定的进度条");
		pb3.setLocation(180,5);
		pb3.setSize(20, 100);

		f.add(pb1);
		f.add(pb2);
		f.add(pb3);

		f.showMe();
	}
}
